package com.baiyang.generator.conf;

import com.baiyang.generator.utils.StringUtil;

// MySQL 8.0 以下版本 - JDBC 驱动名及数据库 URL
//static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";  
//static final String DB_URL = "jdbc:mysql://localhost:3306/baiyang";
// MySQL 8.0 以上版本 - JDBC 驱动名及数据库 URL
//static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";  
//static final String DB_URL = "jdbc:mysql://localhost:3306/baiyang?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";

/** 数据库配置 **/
public class DatabaseConfig {
	private DatabaseConfig() {};
	private static DatabaseConfig config;
	public static DatabaseConfig build() {
		if(config == null) {
			config = new DatabaseConfig();
		}
		return config;
	}
	private String driver;
	private String url;
	private String userName;
	private String password;
	private String tablename;
	public boolean isNotEmpty() {
		if (StringUtil.isEmpty(driver)) {
			System.out.println("driver 不能为空！");
			return true;
		}
		if (StringUtil.isEmpty(url)) {
			System.out.println("url 不能为空！");
			return true;
		}
		if (StringUtil.isEmpty(userName)) {
			System.out.println("userName 不能为空！");
			return true;
		}
		if (StringUtil.isEmpty(password)) {
			System.out.println("password 不能为空！");
			return true;
		}
		if (StringUtil.isEmpty(tablename)) {
			System.out.println("tablename 不能为空！");
			return true;
		}
		return false;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getTablename() {
		return tablename;
	}
	public void setTablename(String tablename) {
		this.tablename = tablename;
	}
	public String getDriver() {
		return driver;
	}
	public void setDriver(String driver) {
		this.driver = driver;
	}
}
